<?php
require 'conn.php';

$order_id = isset($_POST['order_id']) ? intval($_POST['order_id']) : 0;

$response = ['success' => false];

if ($order_id > 0) {
    $sql = "SELECT * FROM reviews WHERE order_id = $order_id";
    $result = $conn->query($sql);

    if ($result && $result->num_rows > 0) {
        $review = $result->fetch_assoc();
        $response['success'] = true;
        $response['data'] = [
            'rating' => $review['rating'],
            'content' => $review['comment']
        ];
    }
}

echo json_encode($response);
?>
